﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>重名查询</title>
    <meta charset='UTF-8'>
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no,email=no" name="format-detection" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
    <link href="../css/alipay/alipay.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/amui-demo_files/toast.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/button.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/amui-demo_files/dialog.css" type="text/css" rel="stylesheet" />
    <link href="../css/alipay/amui-demo_files/button-group.css" type="text/css" rel="stylesheet" />
    <link href="../css/main.css" type="text/css" rel="stylesheet" />
    <link href="../css/dialog.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="../js/extensions/base.js"></script>
    <script type="text/javascript" src="../css/alipay/amui-demo_files/amui.js"></script>
    <style>
        .ui-block-a, .ui-block-b, .ui-block-c, .ui-block-d {
            padding: 10px 0 10px 0;
            text-align: center;
        }

            .ui-block-a img, .ui-block-b img, .ui-block-c img, .ui-block-d img {
                width: 43%;
                padding-top: 10%;
            }

        .am-button {
            padding-LEFT: 15PX;
        }
        .am-list:not([am-version]){padding: 0px;}
    </style>
    <script type="text/javascript">
        $(function(){
            /*$("#dialogbut").click(function(){
             $(".mask").show();
             $(".demo-content").show();
             });*/

            $(".am-dialog-button").click(function(){
                $(".mask").hide();
                $(".demo-content").hide();
            });

        })
    </script>
</head>
<body>
<div class="mask" style="display: none;"></div>
<div class="demo-content"  style="display: none;">
    <div class="demo-mobile">
        <div class="am-dialog show" style="z-index: 10001;">
            <div class="am-dialog-wrap">
                <div class="am-dialog-body">
                    <p id="warn" class="am-dialog-brief"></p>
                </div>
                <div class="am-dialog-footer">
                    <a class="am-dialog-button">取消</a>
                    <a class="am-dialog-button">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>
    <div data-role="page">
        <div data-role="content" style="background-color:#EFEFF4;padding-top:15PX;">
            <div class="am-list" am-mode="flat form">
                <div class="am-list-body">
                            <div class="am-list-item am-input-autoclear">
                                <div class="am-list-label">查询的姓名</div>
                                <div class="am-list-control">
                                    <input type="text" id="inputName" placeholder="要查询的姓名" value="">
                                    <input type="hidden" placeholder="" value="">
                                    <input type="hidden" id="action" name="action" value=""/>
                                    <input type="hidden" id="command" name="command" value=""/>
                                </div>
                                <div class="am-list-clear"><i class="am-icon-clear am-icon" am-mode="clear"></i></div>
                            </div>
                    <div style="padding-left:15px;padding-right:15px;margin-top:15PX;">
                        <button id="searchButton" type="button" class="am-button" am-mode="blue disabled">查询</button>
                        <button id="resultButton" type="button" class="am-button" am-mode="blue disabled" style="display: none;">查询结果</button>
                    </div>
                </div>
            </div>
        </div>
        <div id="fuwu" style="display: block;font-family:STHeitiSC  ;font-size: 12px; margin-bottom: 15px; margin-left: 0px; width: 100%; text-align: center; position: absolute; bottom: 0px;z-index:-1;">
            <div class="am-agreement am-ft-gray am-ft-sm">
                <p>
                    本服务由吉林省公安厅<br />江苏欧索软件有限公司提供支持
                </p>
            </div>
        </div>
    </div>
    <script>
        var secs = 60;

        $(function () {
            window.setInterval("checkButtonState()", 200);
            $("#searchButton").click(function () {
                var name = $("#inputName").val();
				if(name!="")
				{
                    $.ajax({
                        url: '../../../api/cityservice/name/repeat',
                        type: 'post',
                        data: {"name": name},
                        success: function (resp) {
                            if (resp && resp.succ && resp.statusCode == 100102) {
                                //查询条件提交，等待查询结果
                                $("#action").val("").val(resp.data.action);
                                $("#command").val("").val(resp.data.command);

                                $("#searchButton").hide();
                                for(var i=1;i<=secs;i++) {
                                    window.setTimeout("update(" + i + ")", i * 1000);
                                }
                                $("#resultButton").show();

                            }else if(resp && resp.succ && resp.statusCode == 100101){
                                //查询条件已有查询结果，直接返回结果
                                window.location.href = 'SameNameResult.html?name=' + name;
                            } else {
                                $("#warn").html(resp.msg);
                                $(".mask").show();
                                $(".demo-content").show();
                            }
                        },
                        error: function (){
                            $("#warn").html("查询失败！");
                            $(".mask").show();
                            $(".demo-content").show();
                        }
                    });

				}
            });


            $("#resultButton").click(function(){
                var action = $("#action").val();
                var command = $("#command").val();
                var name = $("#inputName").val();
                $.ajax({
                    url: '../../../api/cityservice/result/gain',
                    type: 'post',
                    data: {"action": action,"command":command},
                    success: function (resp) {
                        if(resp && resp.succ && resp.statusCode == 100101){
                            //查询条件已有查询结果，直接返回结果
                            window.location.href = 'SameNameResult.html?name=' + name;
                        } else {
                            $("#warn").html(resp.msg);
                            $(".mask").show();
                            $(".demo-content").show();

                            $("#inputName").val("");
                            $("#searchButton").show();
                            $("#resultButton").hide();
                            $("#resultButton").attr("am-mode", "blue disabled");
                        }
                    },
                    error: function (){
                        $("#warn").html("查询结果失败！");
                        $(".mask").show();
                        $(".demo-content").show();
                    }
                });
            });
        });

        function checkButtonState() {
            if ($("#inputName").val())
                $("#searchButton").attr("am-mode", "blue");
            else
                $("#searchButton").attr("am-mode", "blue disabled");
        }

        function update(num) {
            if(num == secs) {
                $("#resultButton").text("查询结果");
                $("#resultButton").attr("am-mode", "blue");
            }
            else {
                var printnr = secs-num;
                $("#resultButton").text(printnr +"秒后可查询结果");
            }
        }
    </script>
</body>
</html>
